
*** Regression Analysis
*** Donaubauer, J., Neumayer, E. and Nunnenkamp, P. (2018) Winning or Losing in Investor-to-State Dispute Resolution: The Role of Arbitrator Bias and Experience. 
*** Review of International Economics, 26, 892–916. 
set more off

* set directory

***********************************************************************************

/*change relative path to the directory where the files are located */

***********************************************************************************


global root "d:\Research\Development finance\Nunnenkamp\" 
use "$root/master_dispute_settlement.dta", clear

global experience "experience_respondent experience_claimant experience_president"
global bias "bias_respondent bias_claimant bias_president"
global controls_respondent "ln_gdp_pc_respondent gdpconstant_ln_respondent rulelaw_wgi_respondent"
global controls_claimant "ln_gdp_pc_investor gdpconstant_ln_investor eu_investor nafta_investor"
global timedummies "perioddummy*" 
global rules_institutions " bit_dummy energy_charter_dummy rules_icsid_dummy rules_icsid_af_dummy rules_uncitral_dummy "


* Table 2
* baseline
logit outcome_favour_investor_extended $experience $bias $rules_institutions sectordummy* $timedummies, robust
outreg2 using "$root/Table2_baseline.xls", keep ($experience $bias ) ctitle() replace addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES)

* baseline + controls 
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy* $timedummies, robust
outreg2 using "$root/Table2_baseline.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle() append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*)

********************************
* robustness I (= Table 4 in paper)
* baseline + controls 
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust 
outreg2 using "$root/Table4.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(baseline) replace  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions)

/*
* Note that we are not allowed to make the ICRG data that we have used in the following two estimations publicly available.
* These data are commercially available at https://epub.prsgroup.com/prepared-icrg-datasets

* baseline + controls (property rights (=icrg investment profile) instead of rule of law)
logit outcome_favour_investor_extended $experience $bias ln_gdp_pc_respondent gdpconstant_ln_respondent investment_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
outreg2 using "$root/Table4.xls", keep ($experience $bias ln_gdp_pc_respondent gdpconstant_ln_respondent investment_respondent $controls_claimant) ctitle() append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias ln_gdp_pc_respondent gdpconstant_ln_respondent investment_respondent $controls_claimant $rules_institutions)

* baseline + controls (regulatory effectiveness (= icrg bureaucracy quality) instead of rule of law)
logit outcome_favour_investor_extended $experience $bias ln_gdp_pc_respondent gdpconstant_ln_respondent bureaucracy_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
outreg2 using "$root/Table4.xls", keep ($experience $bias ln_gdp_pc_respondent gdpconstant_ln_respondent bureaucracy_respondent $controls_claimant) ctitle() append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias ln_gdp_pc_respondent gdpconstant_ln_respondent rulelaw_wgi_respondent investment_respondent bureaucracy_respondent $controls_claimant $rules_institutions)
*/

* modified bias
gen bias_respondent2 = bias_respondent/experience_respondent
replace bias_respondent2=0 if experience_respondent==0
gen bias_claimant2 = bias_claimant/experience_claimant
replace bias_claimant2=0 if experience_claimant==0
gen bias_president2 = bias_president/experience_president
replace bias_president2=0 if experience_president==0
*global bias2 "bias_respondent2 bias_claimant2 bias_president2"

logit outcome_favour_investor_extended $experience bias_respondent2 bias_claimant2 bias_president2 $controls_respondent $controls_claimant $rules_institutions sectordummy* $timedummies, robust
outreg2 using "$root/Table4.xls", keep ($experience bias_respondent2 bias_claimant2 bias_president2 $controls_respondent $controls_claimant) ctitle() append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias bias_respondent2 bias_claimant2 bias_president2 $controls_respondent $controls_claimant $rules_institutions sectordummy*)

* combined measures for bias and experience
logit outcome_favour_investor_extended experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions sectordummy* $timedummies, robust
outreg2 using "$root/Table4.xls", keep (experience_combined bias_combined $controls_respondent $controls_claimant) ctitle() append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions)

* drop extreme values for experience
preserve
qui logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
egen raus=pctile(experience_combined) if e(sample), p(5)
drop if experience_combined<=raus & e(sample)
egen raus2=pctile(experience_combined) if e(sample), p(95)
drop if experience_combined>=raus2 & e(sample)
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
outreg2 using "$root/Table4.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(drop extreme experience) append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions)
restore

* drop extreme values for bias
preserve
qui logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
egen raus=pctile(bias_combined) if e(sample), p(5)
drop if bias_combined<=raus & e(sample)
egen raus2=pctile(bias_combined) if e(sample), p(95)
drop if bias_combined>=raus2 & e(sample)
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
outreg2 using "$root/Table4.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(drop extreme bias) append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions)
restore

* developing respondent states only
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies if incomegroup_fix_respondent!="H", robust
outreg2 using "$root/Table4.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(developing respondents) append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions)

* drop potentially incomplete early years (especially before 1999)
preserve
drop if year<2002
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
outreg2 using "$root/Table4.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(drop early years) append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions)
restore

* outcome_favour_investor 
logit outcome_favour_investor $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
outreg2 using "$root/Table4.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle() append addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent ln_gdp_pc_investor gdpconstant_ln_investor nafta_investor eu_investor  rulelaw_wgi_respondent investment_respondent bureaucracy_respondent $controls_claimant $rules_institutions)
********************************


********************************
* robustness II (= Table 5 in paper)

* baseline
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions  sectordummy*  $timedummies, robust
outreg2 using "$root/Table5.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(baseline) replace  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions)

* LPM
regress outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions  sectordummy*  $timedummies if e(sample), robust
outreg2 using "$root/Table5.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(LPM) append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions)

* probit 
probit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
outreg2 using "$root/Table5.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(probit) append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions)

* ordered logit
* original DV outcome_favour_investor: 1 investor, 0 state
* 0 state + discontinued, 1 settlement, 2 claimant
gen outcome_ordered=.
replace outcome_ordered = 0 if outcome_detailed == "Decided in favour of State" | outcome_detailed == "Discontinued"
replace outcome_ordered = 1 if outcome_detailed == "Settled"
replace outcome_ordered = 2 if outcome_detailed == "Decided in favour of investor"

version 14.2: ologit outcome_ordered $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy1-sectordummy3  perioddummy1-perioddummy6, robust
outreg2 using "$root/Table5.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(ologit) append addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias $controls_respondent $controls_claimant $rules_institutions)

* ordered logit II
* 0 state, 1 discontinued, 2 settlement, 3 claimant
gen outcome_ordered2=.
replace outcome_ordered2 = 0 if outcome_detailed == "Decided in favour of State" 
replace outcome_ordered2 = 1 if outcome_detailed == "Discontinued"
replace outcome_ordered2 = 2 if outcome_detailed == "Settled"
replace outcome_ordered2 = 3 if outcome_detailed == "Decided in favour of investor"

version 14.2: ologit outcome_ordered2 $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
outreg2 using "$root/Table5.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(ologit) append addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias $controls_respondent $controls_claimant $rules_institutions)

* ordered logit III
* 0 state + discontinued, 1 settlement, 2 major win claimant 3 minor win claimant
capture dropvars amount_relative outcome_ordered3
gen amount_relative=(amount_awarded/amount_claimed)*100
gen outcome_ordered3=.
version 14.2: ologit outcome_ordered2 $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust
sum amount_relative if e(sample), detail
replace outcome_ordered3 = 0 if outcome_detailed == "Decided in favour of State" | outcome_detailed == "Discontinued"
replace outcome_ordered3 = 1 if outcome_detailed == "Settled"
replace outcome_ordered3 = 2 if outcome_detailed == "Decided in favour of investor" & amount_relative<r(p50)
replace outcome_ordered3 = 3 if outcome_detailed == "Decided in favour of investor" & amount_relative>=r(p50) & amount_relative!=.

version 14.2: ologit outcome_ordered3 $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy*  $timedummies, robust

outreg2 using "$root/Table5.xls", keep ($experience $bias $controls_respondent $controls_claimant) ctitle(ologit minor-major) append /*addstat(log likelihood, `e(ll)' ) */ addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias $controls_respondent $controls_claimant $rules_institutions)
********************************


*************************************
* Interactions 
* effects of president's bias conditional on XX
* estimations (outreg to table)
gen bias_president_bias_resp=c.bias_president#c.bias_respondent
gen bias_president_exp_resp=c.bias_president#c.experience_respondent

* case1: 
* interact the bias of presidents with the bias of state-appointed arbitrators
qui logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy* bias_president_bias_resp $timedummies, robust
outreg2 using "$root/Table3_interactions.xls", keep ( $experience $bias $controls_respondent $controls_claimant bias_president_bias_resp ) ctitle() excel title (Table 3) replace addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias $controls_respondent $controls_claimant $rules bias_president_bias_resp)

* case2: 
* interact the bias of presidents with the experience of state-appointed arbitrators
qui logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions  sectordummy* bias_president_exp_resp $timedummies, robust
outreg2 using "$root/Table3_interactions.xls", keep ( $experience $bias $controls_respondent $controls_claimant  bias_president_exp_resp ) ctitle() excel title () append addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias $controls_respondent $controls_claimant $rules bias_president_bias_resp bias_president_exp_resp)

* estimations: marginal effects (graph export)
* case1: 
* interact the bias of presidents with the bias of state-appointed arbitrators
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy* c.bias_president#c.bias_respondent $timedummies, robust
margins, dydx(bias_president) at((p05) bias_respondent) at((p15) bias_respondent)  at((p25) bias_respondent)  at((p35) bias_respondent) ///
at((p45) bias_respondent) at((p55) bias_respondent) at((p65) bias_respondent) at((p75) bias_respondent)  at((p85) bias_respondent) at((p95) bias_respondent)
marginsplot, xtitle(bias of state-appointed arbitrator) ytitle("") title (Predicted effect of president's bias) graphregion(color(white)) bgcolor(white) ///
xlabel( `=1' "p(5)" `=2' "p(15)" `=3' "p(25)" `=4' "p(35)" `=5' "p(45)" `=6' "p(55)" `=7' "p(65)" `=8' "p(75)" `=9' "p(85)" `=10' "p(95)")  
graph export "$root/bias_pres_bias_resp.pdf", as(pdf) replace

* case2: 
* interact the bias of presidents with the experience of state-appointed arbitrators
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy* c.bias_president#c.experience_respondent $timedummies, robust
margins, dydx(bias_president) at((p05) experience_respondent) at((p15) experience_respondent)  at((p25) experience_respondent)  at((p35) experience_respondent) ///
at((p45) experience_respondent) at((p55) experience_respondent) at((p65) experience_respondent) at((p75) experience_respondent)  at((p85) experience_respondent) at((p95) experience_respondent)
marginsplot, xtitle(experience of state-appointed arbitrator) ytitle("") title (Predicted effect of president's bias) graphregion(color(white)) bgcolor(white) ///
xlabel( `=1' "p(5)" `=2' "p(15)" `=3' "p(25)" `=4' "p(35)" `=5' "p(45)" `=6' "p(55)" `=7' "p(65)" `=8' "p(75)" `=9' "p(85)" `=10' "p(95)")  
graph export "$root/bias_pres_experience_resp.pdf", as(pdf) replace

* estimations (outreg to table)
gen bias_president_exp_claimant=c.bias_president#c.experience_claimant
gen bias_president_bias_claimant = c.bias_president#c.bias_claimant

* 1) Bias president mit Bias claimant
qui logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy* bias_president_bias_claimant $timedummies, robust
outreg2 using "$root/Table3_interactions.xls", keep ( $experience $bias $controls_respondent $controls_claimant  bias_president_bias_claimant ) ctitle() excel title () append addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias $controls_respondent $controls_claimant $rules bias_president_bias_resp bias_president_exp_resp bias_president_bias_claimant bias_president_exp_claimant )

* 2) Bias president mit Experience claimant
qui logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy* bias_president_exp_claimant $timedummies, robust
outreg2 using "$root/Table3_interactions.xls", keep ( $experience $bias $controls_respondent $controls_claimant bias_president_exp_claimant ) ctitle() excel title () append addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias $controls_respondent $controls_claimant $rules bias_president_bias_resp bias_president_exp_resp bias_president_bias_claimant bias_president_exp_claimant)

* estimations: marginal effects (graph export)
* 1) Bias president mit Bias claimant
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy* c.bias_president#c.bias_claimant $timedummies, robust
margins, dydx(bias_president) at((p05) bias_claimant) at((p15) bias_claimant)  at((p25) bias_claimant)  at((p35) bias_claimant) ///
at((p45) bias_claimant) at((p55) bias_claimant) at((p65) bias_claimant) at((p75) bias_claimant)  at((p85) bias_claimant) at((p95) bias_claimant)
marginsplot, xtitle(bias of claimant-appointed arbitrator) ytitle("") title (Predicted effect of president's bias) graphregion(color(white)) bgcolor(white) ///
xlabel( `=1' "p(5)" `=2' "p(15)" `=3' "p(25)" `=4' "p(35)" `=5' "p(45)" `=6' "p(55)" `=7' "p(65)" `=8' "p(75)" `=9' "p(85)" `=10' "p(95)")  
graph export "$root/bias_president_bias_claimant.pdf", as(pdf) replace

* 2) Bias president mit Experience claimant
logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy* c.bias_president#c.experience_claimant $timedummies, robust
margins, dydx(bias_president) at((p05) experience_claimant) at((p15) experience_claimant)  at((p25) experience_claimant)  at((p35) experience_claimant) ///
at((p45) experience_claimant) at((p55) experience_claimant) at((p65) experience_claimant) at((p75) experience_claimant)  at((p85) experience_claimant) at((p95) experience_claimant)
marginsplot, xtitle(experience of claimant-appointed arbitrator) ytitle("") title (Predicted effect of president's bias) graphregion(color(white)) bgcolor(white) ///
xlabel( `=1' "p(5)" `=2' "p(15)" `=3' "p(25)" `=4' "p(35)" `=5' "p(45)" `=6' "p(55)" `=7' "p(65)" `=8' "p(75)" `=9' "p(85)" `=10' "p(95)")  
graph export "$root/bias_president_experience_claimant.pdf", as(pdf) replace


*********************
* multiple imputation
xtset, clear
mi set mlong
mi register imputed $experience $bias 

* analyse missings
drop if year==2016 /* basically no data at all */
mdesc  $experience $bias $controls_respondent $controls_claimant $rules_institutions

* im estimate
mi impute mvn $experience $bias  = $controls_respondent $controls_claimant $rules_institutions sectordummy* $timedummies, add(10) rseed (53421) force
mi estimate, dots post: logit outcome_favour_investor_extended $experience $bias $controls_respondent $controls_claimant $rules_institutions sectordummy* $timedummies, robust
outreg2 using "$root/Table4.xls",  keep ($experience $bias $controls_respondent $controls_claimant) ctitle(imputed) append  addtext (Time dummies, YES, Sector dummies, YES, Treaty and institution dummies, YES) ///
sortvar ( $experience $bias experience_combined bias_combined $controls_respondent $controls_claimant $rules_institutions sectordummy*)









